/*
 * Copyright (c) 2024-2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


// WARNING! THIS FILE IS AUTO-GENERATED, DO NOT MAKE CHANGES, THEY WILL BE LOST ON NEXT GENERATION!

import { int32, float32 } from "@koalaui/common"
import { nullptr, KPointer, KInt, KBoolean, KStringPtr } from "@koalaui/interop"
import { isResource, isInstanceOf, runtimeType, RuntimeType } from "@koalaui/interop"
import { Serializer } from "./Serializer"
import { ComponentBase } from "../ComponentBase"
import { PeerNode } from "../PeerNode"
import { ArkUIGeneratedNativeModule } from "#components"
import { ArkBaseSpanPeer, ArkBaseSpanAttributes } from "./ArkSpanPeer"
import { BaseSpan } from "./../ArkSpanInterfaces"
import { ImageSpanAttribute, ImageCompleteCallback } from "./../ArkImageSpanInterfaces"
import { ImageSpanAlignment, ImageFit } from "./../ArkEnumsInterfaces"
import { ColorFilter } from "./../ArkColorFilterMaterialized"
import { DrawingColorFilter, ImageErrorCallback } from "./../ArkImageInterfaces"
import { PixelMap } from "./../ArkPixelMapMaterialized"
import { ResourceStr } from "./../ArkUnitsInterfaces"
import { Resource } from "./../ArkResourceInterfaces"
import { CallbackKind } from "./CallbackKind"
import { CallbackTransformer } from "./CallbackTransformer"
import { TypeChecker } from "#components"
import { wrapCallback } from "@koalaui/interop"
import { MaterializedBase } from "./../MaterializedBase"
import { DotIndicator } from "./../ArkDotIndicatorBuilder"
import { DigitIndicator } from "./../ArkDigitIndicatorBuilder"
import { SubTabBarStyle } from "./../ArkSubTabBarStyleBuilder"
import { BottomTabBarStyle } from "./../ArkBottomTabBarStyleBuilder"
export class ArkImageSpanPeer extends ArkBaseSpanPeer {
    protected constructor(peerPtr: KPointer, id: int32, name: string = "", flags: int32 = 0) {
        super(peerPtr, id, name, flags)
    }
    public static create(component?: ComponentBase, flags: int32 = 0): ArkImageSpanPeer {
        const peerId  = PeerNode.nextId()
        const _peerPtr  = ArkUIGeneratedNativeModule._ImageSpan_construct(peerId, flags)
        const _peer  = new ArkImageSpanPeer(_peerPtr, peerId, "ImageSpan", flags)
        component?.setPeer(_peer)
        return _peer
    }
    setImageSpanOptionsAttribute(value: ResourceStr | PixelMap): void {
        const thisSerializer : Serializer = Serializer.hold()
        let value_type : int32 = RuntimeType.UNDEFINED
        value_type = runtimeType(value)
        if ((((RuntimeType.STRING == value_type))) || (((RuntimeType.OBJECT == value_type)))) {
            thisSerializer.writeInt8(0 as int32)
            const value_0  = value as ResourceStr
            let value_0_type : int32 = RuntimeType.UNDEFINED
            value_0_type = runtimeType(value_0)
            if (((RuntimeType.STRING == value_0_type))) {
                thisSerializer.writeInt8(0 as int32)
                const value_0_0  = value_0 as string
                thisSerializer.writeString(value_0_0)
            }
            else if (((RuntimeType.OBJECT == value_0_type))) {
                thisSerializer.writeInt8(1 as int32)
                const value_0_1  = value_0 as Resource
                thisSerializer.writeResource(value_0_1)
            }
        }
        else if (((RuntimeType.OBJECT) == (value_type)) && (TypeChecker.isPixelMap(value, false, false))) {
            thisSerializer.writeInt8(1 as int32)
            const value_1  = value as PixelMap
            thisSerializer.writePixelMap(value_1)
        }
        ArkUIGeneratedNativeModule._ImageSpanInterface_setImageSpanOptions(this.peer.ptr, thisSerializer.asArray(), thisSerializer.length())
        thisSerializer.release()
    }
    verticalAlignAttribute(value: ImageSpanAlignment): void {
        ArkUIGeneratedNativeModule._ImageSpanAttribute_verticalAlign(this.peer.ptr, (value.valueOf() as int32))
    }
    colorFilterAttribute(value: ColorFilter | DrawingColorFilter): void {
        const thisSerializer : Serializer = Serializer.hold()
        let value_type : int32 = RuntimeType.UNDEFINED
        value_type = runtimeType(value)
        if (((RuntimeType.OBJECT) == (value_type)) && (TypeChecker.isColorFilter(value))) {
            thisSerializer.writeInt8(0 as int32)
            const value_0  = value as ColorFilter
            thisSerializer.writeColorFilter(value_0)
        }
        else if (TypeChecker.isDrawingColorFilter(value, false)) {
            thisSerializer.writeInt8(1 as int32)
            const value_1  = value as DrawingColorFilter
            thisSerializer.writeDrawingColorFilter(value_1)
        }
        ArkUIGeneratedNativeModule._ImageSpanAttribute_colorFilter(this.peer.ptr, thisSerializer.asArray(), thisSerializer.length())
        thisSerializer.release()
    }
    objectFitAttribute(value: ImageFit): void {
        ArkUIGeneratedNativeModule._ImageSpanAttribute_objectFit(this.peer.ptr, (value.valueOf() as int32))
    }
    onCompleteAttribute(value: ImageCompleteCallback): void {
        const thisSerializer : Serializer = Serializer.hold()
        thisSerializer.holdAndWriteCallback(value)
        ArkUIGeneratedNativeModule._ImageSpanAttribute_onComplete(this.peer.ptr, thisSerializer.asArray(), thisSerializer.length())
        thisSerializer.release()
    }
    onErrorAttribute(value: ImageErrorCallback): void {
        const thisSerializer : Serializer = Serializer.hold()
        thisSerializer.holdAndWriteCallback(value)
        ArkUIGeneratedNativeModule._ImageSpanAttribute_onError(this.peer.ptr, thisSerializer.asArray(), thisSerializer.length())
        thisSerializer.release()
    }
    altAttribute(value: PixelMap): void {
        const thisSerializer : Serializer = Serializer.hold()
        thisSerializer.writePixelMap(value)
        ArkUIGeneratedNativeModule._ImageSpanAttribute_alt(this.peer.ptr, thisSerializer.asArray(), thisSerializer.length())
        thisSerializer.release()
    }
}
export interface ArkImageSpanAttributes extends ArkBaseSpanAttributes {
    verticalAlign?: ImageSpanAlignment
    colorFilter?: ColorFilter | DrawingColorFilter
    objectFit?: ImageFit
    onComplete?: ImageCompleteCallback
    onError?: ImageErrorCallback
    alt?: PixelMap
}
